package block;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class SocketClient {

    public static void main(String[] args) throws IOException {
        String host = "127.0.0.1";
        int port = 50000;
        Socket socket = new Socket(host, port);
        OutputStream outputStream = socket.getOutputStream();
        String s = "hello 1111111";
        outputStream.write(s.getBytes("utf-8"));
        socket.shutdownOutput();
        InputStream inputStream = socket.getInputStream();
        byte[] buf = new byte[16];
        int len = 0;
        StringBuffer sb = new StringBuffer();
        while ((len = inputStream.read(buf)) != -1){
            sb.append(new String(buf, 0, len, "utf-8"));
        }
        System.out.println(sb.toString());
        outputStream.close();
        inputStream.close();
        socket.close();
    }

}
